package com.yc.navy.goods.service.lmpl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yc.navy.goods.bean.MemberInfo;
import com.yc.navy.goods.dto.PasswordDTO;
import com.yc.navy.goods.dto.PayInfoDTO;
import com.yc.navy.goods.enums.ResultEnum;
import com.yc.navy.goods.mapper.IMemberInfoMapper;
import com.yc.navy.goods.service.IMemberInfoService;
import com.yc.navy.goods.util.FindByPageParamUtil;
import com.yc.navy.goods.util.StringUtil;
import com.yc.navy.goods.vo.StreamVO;

@Service
public class MemberInfoServiceImpl implements IMemberInfoService{
	@Autowired
	private IMemberInfoMapper memberInfoMapper;

	@Override
	public int reg(MemberInfo mf) {
		if(StringUtil.checkNull(mf.getNickName(),mf.getRealName(),mf.getEmail(),mf.getPwd())) {
			return -1;
		}
		return memberInfoMapper.reg(mf);
	}

	@Override
	public MemberInfo login(MemberInfo mf) {
		return memberInfoMapper.login(mf);
	}

	@Override
	public int repassword(MemberInfo mf) {
		if(mf.getNickName() == null && "".equals(mf.getNickName()) && mf.getTel() == null && "".equals(mf.getTel())  ) {
			return -1;
		}
		return memberInfoMapper.repassword(mf);
	}

	@Override
	public String getRepwdEmail(MemberInfo mf) {
		return memberInfoMapper.getRepwdEmail(mf);
	}

	@Override
	public List<MemberInfo> finds() {
		return memberInfoMapper.finds();
	}
	
	@Override
	public StreamVO findByPageForBack(Map<String, Object> map) {
		List<MemberInfo> list = memberInfoMapper.findByPage(FindByPageParamUtil.StreamVOfindByPageParam(map));
		if(list == null || list.isEmpty()) {
			return new StreamVO(ResultEnum.NOTFOUND);
		}
		return new StreamVO(list,memberInfoMapper.total());
	}

	@Override
	public int addNumber(long mid) {
		return memberInfoMapper.addNumber(mid);
	}

	@Override
	public int updateprice(PayInfoDTO pay) {
		if(StringUtil.checkNull(pay.getMid(),pay.getTotalprice())) {
			return -1;
		}
		return memberInfoMapper.updateprice(pay);
	}

	@Override
	public int updateMember(MemberInfo mf) {
		return memberInfoMapper.updateMember(mf);
	}

	@Override
	public int updatepassword(PasswordDTO pwd) {
		return memberInfoMapper.updatepassword(pwd);
	}

	@Override
	public MemberInfo rechecklogin(Integer mid) {
		return memberInfoMapper.rechecklogin(mid);
	}

	@Override
	public Integer updataPhoto(Map<String, Object> map) {
		if(StringUtil.checkNull(map.get("photo"),String.valueOf(map.get("mid")))) {
			return -1;
		}
		return memberInfoMapper.updataPhoto(map);
	}
}
